- CPU is main controller; it gives tasks to GPU and waits for results and receive results from GPU, so we can't replace CPU with GPU. GPU is co-processor and it only handles compute intensive tasks.
-
CPU and GPU are on same mother board, they have separate memory to handle serial and parallel tasks respectively.
CPU GPU sophisticated control unit less sophisticated control unit Larger cache smaller cache Less area for cores (20% of total area) more area for cores (80% of total area) More DRAM often less VRAM than CPU Faster clock Less powerful clock
We also use GPU for display. (To change colors simultaneously)
GPC- Graphic Processing Cluster
SM- Streaming Multiprocessor
core-CUDA cores
SFU-special function unit (trigonometric functions, logarithmic functions )
Multiple cores make up one SM, multiple SM makes one GPC, multiple GPC makes GPU.
nvcc- nvidia cuda compiler
- Threads are group together to form Thread blocks.
- group of blocks are termed as Grid.
Threads-> Blocks -> Grids
example: gpufunction<<<N_blocks, N_threads_per_block>>>();
or : gpufunction<<<gridDim.x, blockDim.x>>>();
- Addtwovectors<<<2,4>>>(); Here 2 blocks and each block has 4 threads. This function will be executed 8 times.
- Limit: max number of threads per block is 1024, max number of blocks per grid depends upon architecture.
- threadIdx.x = thread Id local to a given block blockIdx.x = block Id local to a grid blockDim.x = number of threads per block gridDim.x = number of blocks per grid
- Global ID of thread in presence of multiple blocks = threadIdx.x + blockIdx.x + blockDim.x